package com.example.web;

import com.alibaba.fastjson.JSON;
import com.example.mapper.UserMapper;
import com.example.model.User;
import com.example.service.UserService;
import com.example.util.SpringContext;
import com.example.util.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: ym
 * @create: 2019-08-09
 **/
@Controller
public class HelloController {

    @Autowired
    UserMapper userMapper;

    @RequestMapping("/hellodate")
    @ResponseBody
    public String hello(){
        UserService userService = SpringUtils.getBean(UserService.class);
        User user = userService.getUser(1L);
        return JSON.toJSONString(user);
    }

    @RequestMapping("/hellodate2")
    @ResponseBody
    public String hello2(){
        UserService userService = SpringContext.getBean(UserService.class);
        return JSON.toJSONString(userService.getUser(1L));
    }

}
